package io.kiki.sba.registry.common.model;

import lombok.Getter;
import lombok.Setter;

import java.util.Objects;

@Setter
@Getter
public final class Triple<F, M, L> {

    private final F first;

    private final M middle;

    private final L last;

    public Triple(F first, M middle, L last) {
        this.first = first;
        this.middle = middle;
        this.last = last;
    }

    public static <F, M, L> Triple<F, M, L> from(F first, M middle, L last) {
        return new Triple<F, M, L>(first, middle, last);
    }

    public F getFirst() {
        return this.first;
    }

    public L getLast() {
        return this.last;
    }

    public M getMiddle() {
        return this.middle;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        Triple<?, ?, ?> triple = (Triple<?, ?, ?>) o;
        return Objects.equals(first, triple.first) && Objects.equals(middle, triple.middle) && Objects.equals(last, triple.last);
    }

    @Override
    public int hashCode() {
        return Objects.hash(first, middle, last);
    }

    public int size() {
        return 3;
    }


}
